package com.ruoyi.api.controller;

import com.ruoyi.api.domain.Merchant;
import com.ruoyi.api.domain.ShoppingCart;
import com.ruoyi.api.service.IShoppingCartService;
import com.ruoyi.api.vo.ShoppingCartVo;
import com.ruoyi.api.vo.ShoppingCartsVo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 购物车
 *
 * @author 寻觅
 * @since 2025-05-29
 */
@RestController
@RequestMapping("/shopping/cart")
public class ShoppingCartController extends BaseController {

    @Autowired
    IShoppingCartService shoppingCartService;

    /**
     * 获取用户购物车
     */
    @GetMapping("/list")
    public AjaxResult userList(@RequestParam Long userId) {
        return AjaxResult.success(shoppingCartService.selectData(userId));
    }
    /**
     * 添加
     */
    @PostMapping("add")
    public AjaxResult add(@RequestBody ShoppingCart shoppingCart){
        return AjaxResult.success(shoppingCartService.add(shoppingCart));
    }

}
